package krow.dev.gunpobus.control;

import java.util.List;

import krow.dev.gunpobus.GlobalStore;
import krow.dev.gunpobus.control.database.DataController;
import krow.dev.gunpobus.model.FavoriteItem;
import android.os.AsyncTask;

public class FavoriteSelectTask extends AsyncTask<Void, Void, Void>{

	private DataController mDataController;

	private OnCompletionListener mCompletionListener;

	private List<FavoriteItem> mFavoriteItemList;
	
	public FavoriteSelectTask() {

		mDataController = GlobalStore.getInstance().getDataController();
	}
	
	public void setCompletionListener(OnCompletionListener completionListener){
		
		mCompletionListener = completionListener;
	}
	
	@Override
	protected void onPreExecute() {
		
	}
	
	@Override
	protected Void doInBackground(Void... params) {

		mFavoriteItemList = mDataController.getFavoriteItemList();
		
		return null;
	}

	@Override
	protected void onPostExecute(Void result) {

		if(mCompletionListener != null){
			mCompletionListener.onCompletion(mFavoriteItemList);
		}
	}
	
	public interface OnCompletionListener{
		
		public abstract void onCompletion(List<FavoriteItem> favoriteItemList);
	}
}
